###############################################################################
##
## $Id$
##
## Copyright (C) 2008 Josh Guilfoyle <jasta@devtcg.org>
##
## This program is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by the
## Free Software Foundation; either version 2, or (at your option) any
## later version.
##
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
###############################################################################

AC_INIT(five-server, 0.0.1, http://five.googlecode.com)
AM_INIT_AUTOMAKE(five-server, 0.0.1)
AM_CONFIG_HEADER(config.h)

AC_PROG_CC
AC_PROG_LIBTOOL

dnl Check headers...

dnl Check courtesy of inotify-tools
dnl XXX: Damnit, GLib seems to offer a file monitor API.  I didn't realize
dnl that when I wrote all this code...
AC_CHECK_HEADERS([sys/inotify.h])
AC_MSG_CHECKING([whether sys/inotify.h actually works])
AC_RUN_IFELSE(
  AC_LANG_PROGRAM([[#include <sys/inotify.h>]],
                  [[return (-1 == inotify_init());]]
  ),
  [AC_MSG_RESULT([yup]); AC_DEFINE([SYS_INOTIFY_H_EXISTS_AND_WORKS],[1],[sys/inotify.h exists and works correctly])],
  [AC_MSG_RESULT([nope, using own inotify headers])]
)

dnl GConf schemas...
AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
AM_CONDITIONAL(USE_GCONFTOOL, test "x$GCONFTOOL" != "xno")
AM_GCONF_SOURCE_2

dnl Check libraries...
PKG_CHECK_MODULES(LIBSYNCML, libsyncml-1.0 >= 0.4.5)
AC_SUBST(LIBSYNCML_CFLAGS)
AC_SUBST(LIBSYNCML_LIBS)

PKG_CHECK_MODULES(LIBSOUP, libsoup-2.2 >= 2.2.91)
AC_SUBST(LIBSOUP_CFLAGS)
AC_SUBST(LIBSOUP_LIBS)

PKG_CHECK_MODULES(SQLITE3, sqlite3)
AC_SUBST(SQLITE3_CFLAGS)
AC_SUBST(SQLITE3_LIBS)

PKG_CHECK_MODULES(TAGLIB, taglib)
AC_SUBST(TAGLIB_CFLAGS)

# Hack to use the C bindings.  There should be a separate pkg-config entry for
# this, but there doesn't seem to be.
TAGLIB_LIBS="-ltag_c"
AC_SUBST(TAGLIB_LIBS)

PKG_CHECK_MODULES(WAND, Wand)
AC_SUBST(WAND_CFLAGS)
AC_SUBST(WAND_LIBS)

PKG_CHECK_MODULES(GLIB, glib-2.0 gthread-2.0 gmodule-2.0)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)

PKG_CHECK_MODULES(GCONF, gconf-2.0)
AC_SUBST(GCONF_CFLAGS)
AC_SUBST(GCONF_LIBS)

PKG_CHECK_MODULES(GTK, gtk+-2.0)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)

PKG_CHECK_MODULES(LIBGLADE, libglade-2.0)
AC_SUBST(LIBGLADE_CFLAGS)
AC_SUBST(LIBGLADE_LIBS)

PKG_CHECK_MODULES(LIBSEXY, libsexy)
AC_SUBST(LIBSEXY_CFLAGS)
AC_SUBST(LIBSEXY_LIBS)

dnl i18n
dnl GETTEXT_PACKAGE=five
dnl AC_SUBST(GETTEXT_PACKAGE)
dnl AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Define the Gettext package name])
dnl AM_GLIB_GNU_GETTEXT

dnl Generate real build environment...
AC_CONFIG_FILES([Makefile
	po/Makefile.in
	data/Makefile
	data/pixmaps/Makefile
	data/glade/Makefile
	src/Makefile
	src/ui/Makefile
	src/ui/gtk/Makefile])

AC_OUTPUT
